package commonUtils.config;


import commonUtils.entities.Restful;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import static commonUtils.utils.CURDConstant.SYSTEM_ERROR;

/**
 * 自定义异常处理器，监控出现的异常
 */
@Slf4j
@RestControllerAdvice
public class WebExceptionAdvice {

    @ExceptionHandler(RuntimeException.class)
    public Restful handleRuntimeException(RuntimeException e) {
        log.error(e.toString(), e);
        return new Restful(SYSTEM_ERROR,"服务器异常");
    }
}
